package cn.edu.neusoft.yuejian4.yuejian_4.activity;

import android.os.Bundle;
import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import java.util.List;

import cn.edu.neusoft.yuejian4.yuejian_4.R;
import cn.edu.neusoft.yuejian4.yuejian_4.adapter.GameListAdapter;
import cn.edu.neusoft.yuejian4.yuejian_4.javaBean.Recentgame;
import cn.edu.neusoft.yuejian4.yuejian_4.listener.List_TListener;
import cn.edu.neusoft.yuejian4.yuejian_4.model.GameModel;

/**
 * Created by Lix on 2018/10/18.
 */

public class GameListActivity extends AppCompatActivity implements View.OnClickListener {

    private RecyclerView recyclerView;
    private ImageView back;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game_list);
        initView();
        initEvent();
        GameModel gameModel = new GameModel();
        gameModel.allGame(allGamelistenerr);

    }
    List_TListener<Recentgame> allGamelistenerr =new List_TListener<Recentgame>() {
        @Override
        public void onResponse(List<Recentgame> list) {
            GameListAdapter gameListAdapter = new GameListAdapter(getApplicationContext(),list);
            recyclerView.setAdapter(gameListAdapter);
        }

        @Override
        public void onFail(String msg) {

        }
    };
    private void initView(){
        recyclerView = (RecyclerView)findViewById(R.id.rv_game_list);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
        back = (ImageView)findViewById(R.id.game_list_back);
    }
    private void initEvent(){
        back.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.game_list_back:
                finish();
                break;
        }
    }
}
